﻿myApp.controller("propertyNewController", function ($scope, $http, $modal, modalService, $sce, ngTableParams, $filter,$rootScope) {
    document.title = "Penang Realty 世界地產 New Marketing Project";
    $scope.$emit('newPageLoaded', { 'title': 'Penang Realty 世界地產 Property Directory', 'description': 'Check out our our property directory in Penang.' });
    function pageInit() {
            $scope.loader = { loading: true };
            var url = 'api/PropertyNew/GetPropertyNew';
            $http.get(url).success(function (data) {
                console.log(data);
                $scope.data.Property = data;

                $scope.tableParams = new ngTableParams({
                    page: 1,            // show first page
                    count: 25,           // count per page
                    filter: {
                        ProjectName: ''       // initial filter
                    }

                }, {
                    total: $scope.data.Property.length, // length of data
                    getData: function ($defer, params) {

                        var orderedProperty = params.filter() ? $filter('filter')($scope.data.Property, params.filter()) : $scope.data.Property;
                        // use build-in angular filter
                        orderedProperty = params.sorting() ? $filter('orderBy')(orderedProperty, params.orderBy()) : orderedProperty;
                        params.total(orderedProperty.length); // set total for recalc pagination
                        $defer.resolve(orderedProperty.slice((params.page() - 1) * params.count(), params.page() * params.count()));
                        $scope.loader = { loading: false };
                    }
                })


            })

        }
        pageInit();

})
